<?php
class Shops extends MY_Controller{

	function __construct()
	{
		parent::__construct();
		if(!$this->admin) redirect('admin990/login');
	}

	function index()
	{
		if($_POST){
			$update_shop = shop::find_by_id($_POST['id']);
			$update_shop->shop_name = $_POST['shop_name'];
			$update_shop->address = $_POST['address'];
			$update_shop->tele = $_POST['tele'];
			$update_shop->fax = $_POST['fax'];
			$update_shop->sms = $_POST['sms'];
			$update_shop->open_day = $_POST['open_day'];
			$update_shop->open_hour = $_POST['open_hour'];
			if($update_shop->save())
			{
				$data['msg'] = 'Information du magazin <b>'.$update_shop->shop_name.'</b> a été modifié.';
			}else{
				$data['msg'] = 'Il y a une erreur.';
			}
			$data['title'] = 'Magazins';
			$data['shop'] = shop::find('all');
			$this->load->view('admin/header',$data);
			$this->load->view('admin/shop/index');
		}else{
			$data['title'] = 'Magazins';
			$data['shop'] = shop::find('all');
			$this->load->view('admin/header',$data);
			$this->load->view('admin/shop/index');
		}

	}
}